home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / dvglue10.arc / TVREALOC.C < prev    next >
C/C++ Source or Header  |  1988-08-13  |  1KB  |  39 lines

  1. /*================================================*/
  2. /* TVREALOC.C                                     */
  3. /*                                                */
  4. /* (c) Copyright 1988 Ralf Brown                  */
  5. /*     All Rights Reserved                        */
  6. /* May be freely copied for noncommercial use as  */
  7. /* long as this copyright notice is kept intact   */
  8. /* and any changes are indicated in the comment   */
  9. /* blocks for the functions                       */
  10. /*================================================*/
  11.  
  12. #include "tvapi.h"
  13.  
  14. #undef realloc
  15.  
  16. /*================================================*/
  17.  
  18. extern OBJECT _TV_alloc_mutex_ ;
  19.  
  20. /*================================================*/
  21. /* _TV_realloc  version of realloc which is safe  */
  22. /*            in the presence of multiple threads */
  23. /*   Ralf Brown 5/10/88                           */
  24. /*================================================*/
  25.  
  26. void *_TV_realloc(void *block, size_t size)
  27. {
  28.    void *retval ;
  29.  
  30.    if (!TVisobj(_TV_alloc_mutex_))
  31.       _TV_alloc_mutex_ = TVmbx_new() ;
  32.    TVlock(_TV_alloc_mutex_) ;
  33.    retval = realloc(block, size) ;
  34.    TVunlock(_TV_alloc_mutex_) ;
  35.    return retval ;
  36. }
  37.  
  38. /* End of TVREALOC.C */
  39.